home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
AmigActive 10
/
AACD 10.iso
/
AACD
/
System
/
MCC_SpeedBar
/
Developer
/
C
/
Examples
/
Demo.c
< prev
next >
Wrap
C/C++ Source or Header
|
1999-10-13
|
10KB
|
216 lines
/*
** $Id: Demo.c,v 1.7 1999/09/27 18:16:52 wiz Exp $
*/
/// Include
#include <exec/types.h> // exec
#include <exec/libraries.h>
#include <exec/memory.h>
#include <dos/dos.h> // dos
#include <libraries/mui.h> // libraries
#include <clib/muimaster_protos.h> // clib
#include <clib/alib_protos.h>
#include <proto/exec.h> // proto
#include <proto/dos.h>
#include <proto/muimaster.h>
#include <string.h>
#include <stdio.h>
#include "/SpeedBar_mcc.h"
#include "/SpeedBarCfg/SpeedBarCfg_mcc.h"
#include "MyBrush.h"
///
/// Data
struct Library *MUIMasterBase;
///
/// MakeLabel1
Object *MakeLabel1( STRPTR str )
{
return( MUI_MakeObject( MUIO_Label, str, MUIO_Label_SingleFrame ));
}
///
/// MakeCheck
Object *MakeCheck( STRPTR str )
{
Object *obj = MUI_MakeObject( MUIO_Checkmark, str );
if( obj )
set( obj, MUIA_CycleChain, TRUE );
return( obj );
}
///
/// MakeCycle
Object *MakeCycle( STRPTR *array, STRPTR txt )
{
Object *obj = MUI_MakeObject( MUIO_Cycle, txt, array );
if( obj )
set( obj, MUIA_CycleChain, TRUE );
return( obj );
}
///
int main( int argc, char *argv[] )
{
Object *AppObj, *MainWin, *SpeedBar, *SpeedBar2;
Object *Settings, *update;
BPTR olddir, lock;
static struct MUIS_SpeedBar_Button buttons[] = {
{ 0, "Toggle", "Toggle mode example", MUIV_SpeedBar_ButtonFlag_Toggle, NULL },
{ 1, "Immediate", "Immediate mode example", MUIV_SpeedBar_ButtonFlag_Immediate, NULL },
{ MUIV_SpeedBar_Spacer },
{ 2, "Quit", "This will quit the program", 0, NULL },
{ 2, "Disabled", "This does nothing at all", MUIV_SpeedBar_ButtonFlag_Disabled, NULL },
{ MUIV_SpeedBar_End },
};
static struct MUIS_SpeedBar_Button buttons2[] = {
{ 0, "Toggle", "Toggle mode example", MUIV_SpeedBar_ButtonFlag_Toggle, NULL },
{ 1, "Immediate", "Immediate mode example", MUIV_SpeedBar_ButtonFlag_Immediate, NULL },
{ MUIV_SpeedBar_Spacer },
{ 2, "Quit", "This will quit the program", 0, NULL },
{ 2, "Disabled", "This does nothing at all", MUIV_SpeedBar_ButtonFlag_Disabled, NULL },
{ MUIV_SpeedBar_End },
};
static STRPTR Modes[] = {
"Text + Graphics",
"Graphics only",
"Text only",
NULL
};
static STRPTR Files[] = {
"Pic1.iff",
"Pic2.iff",
"Pic3.iff",
"Spacer.iff"
};
ULONG i;
struct MyBrush *Brushes[4] = { 0 };
if(!( MUIMasterBase = OpenLibrary( "muimaster.library", 19 )))
return( 20 );
if( lock = Lock( "PROGDIR:", ACCESS_READ ))
olddir = CurrentDir( lock );
for( i = 0; i < 4; i++ )
Brushes[ i ] = LoadBrush( Files[ i ]);
if( AppObj = ApplicationObject,
MUIA_Application_Title, "SpeedBar Test",
MUIA_Application_Version, "$VER: SpeedBarTest 1.1 (26.9.99)",
MUIA_Application_Copyright, "Copyright ©1999 by Simone Tellini",
MUIA_Application_Author, "Simone Tellini <wiz@vapor.com>",
MUIA_Application_Description, "Speed(Bar|Button|BarCfg).mcc test program",
MUIA_Application_Base, "SPEEDBARTEST",
SubWindow, MainWin = WindowObject,
MUIA_Window_ID, MAKE_ID( 'M', 'A', 'I', 'N' ),
MUIA_Window_Title, "SpeedBarTest - ©1999 Simone Tellini",
WindowContents, VGroup,
Child, HGroup,
Child, SpeedBar = SpeedBarObject,
MUIA_Group_Horiz, TRUE,
MUIA_SpeedBar_Images, Brushes,
MUIA_SpeedBar_Borderless, FALSE,
MUIA_SpeedBar_ViewMode, MUIV_SpeedBar_ViewMode_TextGfx,
MUIA_SpeedBar_RaisingFrame, FALSE,
MUIA_SpeedBar_Buttons, buttons,
MUIA_SpeedBar_SpacerIndex, 3,
MUIA_SpeedBar_Spread, FALSE,
End,
Child, HSpace( 0 ),
End,
Child, HGroup,
Child, SpeedBar2 = SpeedBarObject,
MUIA_SpeedBar_Images, Brushes,
MUIA_SpeedBar_Borderless, FALSE,
MUIA_SpeedBar_ViewMode, MUIV_SpeedBar_ViewMode_TextGfx,
MUIA_SpeedBar_RaisingFrame, FALSE,
MUIA_SpeedBar_Buttons, buttons2,
MUIA_SpeedBar_SpacerIndex, -1, // no image
MUIA_SpeedBar_Spread, TRUE, // variable spacer size
MUIA_Weight, 1, // minimum width
End,
Child, VGroup,
Child, Settings = SpeedBarCfgObject, End,
Child, update = SimpleButton( "Update" ),
Child, VSpace( 0 ),
End,
End,
End,
End,
End ) {
ULONG sigs = 0, id;
DoMethod( MainWin, MUIM_Notify, MUIA_Window_CloseRequest, TRUE, MUIV_Notify_Application, 2, MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit );
DoMethod( buttons[ 0 ].Object, MUIM_Notify, MUIA_Selected, FALSE, SpeedBar, 5, MUIM_SpeedBar_DoOnButton, 1, MUIM_Set, MUIA_Selected, FALSE );
DoMethod( buttons[ 3 ].Object, MUIM_Notify, MUIA_Pressed, FALSE, AppObj, 2, MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit );
DoMethod( buttons2[ 0 ].Object, MUIM_Notify, MUIA_Selected, FALSE, SpeedBar2, 5, MUIM_SpeedBar_DoOnButton, 1, MUIM_Set, MUIA_Selected, FALSE );
DoMethod( buttons2[ 3 ].Object, MUIM_Notify, MUIA_Pressed, FALSE, AppObj, 2, MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit );
DoMethod( update, MUIM_Notify, MUIA_Pressed, FALSE, AppObj, 2, MUIM_Application_ReturnID, TAG_USER );
set( MainWin, MUIA_Window_Open, TRUE );
while(( id = DoMethod( AppObj, MUIM_Application_NewInput, &sigs )) != MUIV_Application_ReturnID_Quit ) {
if( id == TAG_USER ) {
struct MUIS_SpeedBarCfg_Config *cfg;
get( Settings, MUIA_SpeedBarCfg_Config, &cfg );
set( SpeedBar, MUIA_SpeedBar_ViewMode, cfg->ViewMode );
set( SpeedBar, MUIA_SpeedBar_Borderless, ( cfg->Flags & MUIV_SpeedBarCfg_Borderless ) ? TRUE : FALSE );
set( SpeedBar, MUIA_SpeedBar_RaisingFrame, ( cfg->Flags & MUIV_SpeedBarCfg_Raising ) ? TRUE : FALSE );
set( SpeedBar, MUIA_SpeedBar_SmallImages, ( cfg->Flags & MUIV_SpeedBarCfg_SmallButtons ) ? TRUE : FALSE );
set( SpeedBar, MUIA_SpeedBar_Sunny, ( cfg->Flags & MUIV_SpeedBarCfg_Sunny ) ? TRUE : FALSE );
set( SpeedBar2, MUIA_SpeedBar_ViewMode, cfg->ViewMode );
set( SpeedBar2, MUIA_SpeedBar_Borderless, ( cfg->Flags & MUIV_SpeedBarCfg_Borderless ) ? TRUE : FALSE );
set( SpeedBar2, MUIA_SpeedBar_RaisingFrame, ( cfg->Flags & MUIV_SpeedBarCfg_Raising ) ? TRUE : FALSE );
set( SpeedBar2, MUIA_SpeedBar_SmallImages, ( cfg->Flags & MUIV_SpeedBarCfg_SmallButtons ) ? TRUE : FALSE );
set( SpeedBar2, MUIA_SpeedBar_Sunny, ( cfg->Flags & MUIV_SpeedBarCfg_Sunny ) ? TRUE : FALSE );
}
if( sigs ) {
sigs = Wait( sigs | SIGBREAKF_CTRL_C );
if( sigs & SIGBREAKF_CTRL_C )
break;
}
}
MUI_DisposeObject( AppObj );
}
for( i = 0; i < 4; i++ )
FreeBrush( Brushes[ i ]);
if( lock )
UnLock( CurrentDir( olddir ));
CloseLibrary( MUIMasterBase );
return( 0 );
}